package com.wlyuan.open.domain.api.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

/**
 * @author lijing
 * @description
 */
public class DateUtils {

    public static int between(String start, String end) {
        return Integer.valueOf(between(strToLocalDateTime(start), strToLocalDateTime(end)) + "");
    }

    public static long between(LocalDateTime start, LocalDateTime end) {
        return ChronoUnit.DAYS.between(start, end);
    }

    public static LocalDateTime strToLocalDateTime(String time) {
        return LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

}
